<?php
global $Config;
require_once($Config->WebCMSRoot.'Base/Model.php');
require_once($Config->WebCMSRoot.'Data/Header.php');

Class HeaderModel extends BaseModel
{
	var $Preset;
	var $Title;
	var $Favicon;
	var $Stylesheet;
	var $Style;
	var $Javascript;
	var $JavascriptFile;
	var $HttpEquiv;
	var $Meta;
	var $Conditional;

	function HeaderModel()
	{
		$this->Preset 				= "";
		$this->Title				= "";
		$this->Favicon				= "";
		$this->Stylesheet			= array();
		$this->Style				= "";
		$this->Javascript			= "";
		$this->JavascriptFile		= array();
		$this->HttpEquiv			= array();
		$this->Meta					= array();
		$this->Conditional			= array();
		
		parent::BaseModel();
	}
	
	function Retrieve(&$parameters)
	{
		$db = new HeaderData();
		$this->Parameters = &$parameters;
		
//print('<pre>'.var_export($this, true).'</pre>');//exit;
		$this->Preset = $this->GetParameter('preset');

		if ($this->Preset != '')
		{
			$db->Retrieve(&$this);
		}
		else
		{
			$this->ID     			  = $this->GetParameter('id');
			$this->Title			    = $this->GetParameter('title');
			$this->Favicon			  = $this->GetParameter('favicon');
			$this->Style			    = $this->GetParameter('style');
			$this->Javascript	  	= $this->GetParameter('javascript');

			$this->Stylesheet		  = $this->GetParameter('stylesheet', true);
			$this->JavascriptFile	= $this->GetParameter('javascriptFile', true);
			$this->HttpEquiv		= $this->GetParameter('httpEquiv', true);
			$this->Meta				    = $this->GetParameter('meta', true);
			$this->Conditional          = $this->GetParameter('conditional', true);

      if ($this->Stylesheet == '') { $this->Stylesheet = array(); }
      if ($this->JavascriptFile == '') { $this->JavascriptFile = array(); }
      if ($this->HttpEquiv == '') { $this->HttpEquiv = array(); }
      if ($this->Meta == '') { $this->Meta = array(); }
      if ($this->Conditional == '') { $this->Conditional = array(); }
		}
//print('<pre>'.var_export($this, true).'</pre>');exit;
		
	}

	function Persist()
	{
		$db = new HeaderData();

		$db->Update(&$this);
	}
}
?>